import config from '../config/config';
import request from '../utils/request';

let service = {};


service.prize = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getPrize;
  request({
    url: requestUrl,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}
service.prizes = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getPrize;
  request({
    url: requestUrl,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

service.saveSharePrize = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.saveSharePrize;
  request({
    url: requestUrl,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//用贝壳兑换抽奖机会
service.conchToPrizenum = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.conchToPrizenum;
  request({
    url: requestUrl,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//获取抽奖任务详情
service.getPrizeTask = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getPrizeTask;
  request({
    url: requestUrl,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//抽奖领取（付钱）
service.wxPayMoneyToCustomer = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.wxPayMoneyToCustomer;
  request({
    url: requestUrl,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

module.exports = service;